#include "script/glue/LuaGlue.h"
#include "script/glue/lua/Common.h"
#include <OgreMath.h>

namespace LuaGlue
{
	int Degree::create(lua_State *L)
	{
		Ogre::Degree* d = NULL;

		switch(lua_gettop(L))
			{
			case 0:
				d = new Ogre::Degree();
				break;
			case 1:
				if(lua_isnumber(L, 1))
					{
						d = new Ogre::Degree(luaL_checknumber(L, 1));
						break;
					}
				luaL_error(L, "Wrong type for parameter, expected a number, got %s", lua_typename(L,1) );
				return 0;
				break;
			default:
				luaL_error(L, "Incorrect number of arguments for function");
				return 0;
			}

		Wrapper<Degree>::Instance(L, (void*)d);
		
		return 1;
	}

	int Degree::tostring (lua_State *L)
	{
		Ogre::Degree *d = unwrap<Ogre::Degree>(L, 1);
		lua_pushfstring(L, "Degree(%f)", d->valueDegrees());
		return 1;
	}

	int Degree::valueRadians(lua_State *L)
	{
		Ogre::Degree *d = unwrap<Ogre::Degree>(L, 1);
		lua_pushnumber(L, d->valueRadians());
		return 1;
	}
}

DECLARE(Degree)
META(Degree)
{"__tostring", LuaGlue::Degree::tostring},
METHODS(Degree)
method(LuaGlue::Degree, valueRadians),
END
